package com.flashdeck.domain;

import java.io.File;

import com.flashdeck.utils.DeckHandler;

import junit.framework.TestCase;

public class DeckProgressTest extends TestCase {
	
	public void testDeckProgress() {
		Deck deck = DeckHandler.parseDeck(new File("sample.deck"));
		assertEquals(2, deck.getCards().size());
		int groups = 5;
		
		DeckProgress deckProgress = new DeckProgress(deck.getCards(), deck.getDeckInfo().getId(), groups);
		String nextCardId = deckProgress.getNextCardId();
		assertNotNull(nextCardId);
		
		Card card = deck.getCard(deckProgress.getNextCardId());
		deckProgress.correctAnswer(card);
		assertEquals(1, deckProgress.getCardsInGroup(1));
		assertEquals(1, deckProgress.getCardsInGroup(0));
		deckProgress.correctAnswer(card);
		assertEquals(1, deckProgress.getCardsInGroup(2));
		deckProgress.incorrectAnswer(card);
		assertEquals(0, deckProgress.getCardsInGroup(1));
		assertEquals(0, deckProgress.getCardsInGroup(2));
		assertEquals(2, deckProgress.getCardsInGroup(0));		
	}
}
